﻿using IcsSEMCtrl.Com.Secs;
using IcsSEMCtrl.Service.Alarm;
using IcsSEMCtrl.Service.Material;
using IcsSEMCtrl.Util.Server;
using Lifter.Device;
using Lifter.Device.Dispatcher;
using Lifter.Device.Unit;
using Lifter.Global;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using TKT.Lifter.CIM.Lifter.Global;
using TKT.Lifter.CIM.Lifter.Gui.Monitor.Popups;
using TKT.Lifter.CIM.Lifter.TibcoMsg;
using TKT.Lifter.CIM.Lifter.TibcoMsg.Lifter;
using TKT.Lifter.CIM.Lifter.TibcoMsg.Mes;
using TibcoRv = TIBCO.Rendezvous;

namespace Lifter.Com.Secom
{
    public class TibcoRvComParam
    {
        public string Service { get; set; }
        public string Network { get; set; }
        public string Daemon { get; set; }
        public string Subject { get; set; }

        public TibcoRvComParam(string service, string network, string daemon, string subject)
        {
            this.Service = service;
            this.Network = network;
            this.Daemon = daemon;
            this.Subject = subject;
        }

        public TibcoRvComParam()
            : this("9200", "127.0.0.1", null, "Default")
        {

        }
    }

    public delegate void TibcoRvMessageLogEventHandler(object sender, TibcoRv.Message message);

    public class TibcoRvComDriver : AbstractSecsDriver
    {

        public class TraceRequestData
        {
            /// <summary>
            /// Group Size，群组大小
            /// </summary>
            public int GroupSize { get; set; }

            /// <summary>
            /// 采样模式：-1-连续采样，0-停止采样， 1...n-采样次数
            /// </summary>
            public int TOTSMP { get; set; }

            /// <summary>
            /// 采样时间间隔，单位为毫秒
            /// </summary>
            public double DSPER { get; set; }

            /// <summary>
            /// 采样变量SVID列表
            /// </summary>
            public List<string> SVList { get; set; }

            /// <summary>
            /// Trace Data ID: 1...n
            /// </summary>
            public string TRID { get; set; }

            public TraceRequestData()
            {
                GroupSize = 0;
                TOTSMP = 0;
                DSPER = 5000;
                SVList = new List<string>();
                TRID = "1";
            }
        }

        private TraceRequestData _traceRequestData = new TraceRequestData();
        private int _traceDataSampleNum = 1;

        private TibcoRv.Transport _sendTransport;
        private TibcoRv.Transport _recvTransport;

        private TibcoRv.Transport _sendLogTransport;
        private TibcoRv.Transport _recvLogTransport;

        private string _driverName = "";
        private SecsProperty _secsProperty;

        private TibcoRvComParam _sendComParam = new TibcoRvComParam();
        private TibcoRvComParam _recvComParam = new TibcoRvComParam();

        public override event ReceivedMessage OnReceiveMessage;
        public override event UnknownMessage OnUnknownMessage;
        public override event TimeoutOccured OnTimeoutOccured;
        public override event ReceivedInvalidMessage OnInvalidMessage;
        public override event Connected OnConnected;
        public override event Disconnected OnDisconnected;
        public override event AbortMessage OnAbortMessage;
        public override event Secs1Log OnSecs1Log;
        public override event Secs2Log OnSecs2Log;

        public LifterSEM LftSem = (LifterSEM)Naming.GetDeviceManager().GetDevice();

        public event TibcoRvMessageLogEventHandler OnSendMessageLog;
        public event TibcoRvMessageLogEventHandler OnRecvMessageLog;

        private System.Timers.Timer _traceDataTimer = new System.Timers.Timer();

        public override void Initialize(SecsProperty prop)
        {
            this.Initialize("", prop);
        }

        public override void Initialize(string driverName, SecsProperty prop)
        {
            this._driverName = driverName;
            this._secsProperty = prop;
            //TibcoRv.Environment.Open();
        }

        public override void Open()
        {
            try
            {
                this.IsConnected = false;
                //通讯参数设置
                this._recvComParam = new TibcoRvComParam("9200", ";225.12.12.2", "10.36.160.81:7500", "BOE.BIOT.DEV." + LftSem.HostID);
                this._sendComParam = new TibcoRvComParam("9200", ";225.12.12.2", "10.36.160.81:7500", "BOE.BIOT.MES.PRD.M1.PEMsvr");

                //打开接收端口
                this._recvTransport = new TibcoRv.NetTransport(_recvComParam.Service, _recvComParam.Network, _recvComParam.Daemon);
                TibcoRv.Queue queue = new TibcoRv.Queue();
                TibcoRv.Listener _listener = new TibcoRv.Listener(queue, this._recvTransport, _recvComParam.Subject, null);
                _listener.MessageReceived += _listener_MessageReceived;
                Task.Run(() => DispatchQueueMessage(queue));

                //打开发送端口
                this._sendTransport = new TibcoRv.NetTransport(_sendComParam.Service, _sendComParam.Network, _sendComParam.Daemon);

                //打开发送Log端口
                //this._sendLogTransport = new TibcoRv.NetTransport(_sendComParam.Service, _sendComParam.Network, _sendComParam.Daemon);
                //TibcoRv.Queue queue1 = new TibcoRv.Queue();
                //TibcoRv.Listener _listener1 = new TibcoRv.Listener(queue1, this._recvTransport, _sendComParam.Subject, null);
                //_listener1.MessageReceived += _listener_MessageReceived;
                //Task.Run(() => DispatchQueueMessage(queue1));

                //建立连接
                //EstablishCommunication();
                this.IsConnected = true;

                _traceDataTimer.Elapsed += _traceDataTimer_Elapsed;
                _traceDataTimer.Interval = TimeSpan.FromSeconds(3).TotalMilliseconds;
                _traceDataTimer.Start();
            }
            catch (Exception ex)
            {
                PopupNotice.DialogPopups("打开连接失败，请联系管理员！！\r\n错误描述:" + ex.Message, "Failed to open connection, please contact the administrator!!" + ex.Message, enumPopupsType.Error);
                this.IsConnected = false;
            }
        }

        private void _traceDataTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            _traceDataTimer.Stop();
            try
            {
                if (_traceRequestData.TOTSMP == -1 || _traceRequestData.TOTSMP > 0)
                {
                    TibcoMessage<TraceDataReport> reportMsg = new TibcoMessage<TraceDataReport>();
                    reportMsg.Header.MachineName = this.LftSem.HostID;
                    reportMsg.Header.OriginalSourceSubjectName = _recvComParam.Subject;
                    reportMsg.Header.TransactionId = DateTime.Now.ToString("yyyyMMddHHmmssffffff");

                    reportMsg.Body.MachineName = this.LftSem.HostID;
                    DateTime now = DateTime.Now;
                    reportMsg.Body.STIME = string.Format("{0}{1}", now.ToString("yyyyMMddHHmmss"), ((int)(now.Millisecond / 10)).ToString("00"));
                    reportMsg.Body.TRID = _traceRequestData.TRID;
                    reportMsg.Body.SMPLN = (_traceDataSampleNum++).ToString();
                    reportMsg.Body.UnitList = new List<TraceUnit>();

                    TraceUnit u = new TraceUnit();
                    reportMsg.Body.UnitList.Add(u);

                    u.UnitName = "U01";
                    u.Groups = new List<List<SVData>>();

                    List<SVData> g = new List<SVData>();
                    u.Groups.Add(g);

                    Random r = new Random();
                    foreach (var svid in _traceRequestData.SVList)
                    {
                        SVData svData = new SVData();
                        svData.SVID = svid;
                        svData.Value = r.Next(100).ToString();
                        g.Add(svData);
                    }

                    this.SendMessage(reportMsg.ToMessage());

                    if (_traceRequestData.TOTSMP > 0)
                    {
                        _traceRequestData.TOTSMP--;
                    }

                    if (_traceDataSampleNum >= int.MaxValue)
                    {
                        _traceDataSampleNum = 1;
                    }
                }
            }
            catch (Exception ex)
            {

            }
            _traceDataTimer.Start();
        }

        private bool bReceiveReponsed = false;

        private void EstablishCommunication()
        {
            Task.Run(() =>
            {
                while (true)
                {
                    if (this._sendTransport != null)
                    {
                        bReceiveReponsed = false;
                        TibcoMessage<SubjectReportRequest> subjectReportMsg = new TibcoMessage<SubjectReportRequest>();
                        subjectReportMsg.Header.MachineName = LftSem.HostID;
                        subjectReportMsg.Header.OriginalSourceSubjectName = _recvComParam.Subject;
                        subjectReportMsg.Header.TransactionId = DateTime.Now.ToString("yyyyMMddHHmmssffffff");

                        subjectReportMsg.Body.MachineName = LftSem.HostID;
                        subjectReportMsg.Body.SubjectName = _recvComParam.Subject;

                        this.SendMessage(subjectReportMsg.ToMessage());
                    }
                    System.Threading.Thread.Sleep(3000);
                    if (bReceiveReponsed)
                    {
                        break;
                    }
                }
            });
        }

        private void DispatchQueueMessage(TibcoRv.Queue queue)
        {
            while (true)
            {
                try
                {
                    queue.Dispatch();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
        }

        public void SendMessage(TibcoRv.Message message)
        {
            if (this._sendTransport != null)
            {
                message.SendSubject = _sendComParam.Subject;
             
                this._sendTransport.Send(message);
                if (this.OnSendMessageLog != null)
                {
                    this.OnSendMessageLog(this._sendTransport, message);
                }
            }
        }

        private void _listener_MessageReceived(object listener, TibcoRv.MessageReceivedEventArgs messageReceivedEventArgs)
        {
            TibcoRv.Message message = messageReceivedEventArgs.Message;
            if (this.OnRecvMessageLog != null)
            {
                this.OnRecvMessageLog(this._recvTransport, message);
            }
            MessageHeader msgHeader = new MessageHeader();
            msgHeader.Parse(message);

            if (msgHeader.MessageName == "SubjectReportRequest")
            {
                TibcoMessage<SubjectReportRequest> request = new TibcoMessage<SubjectReportRequest>();
                request.Parse(message);
                TibcoMessage<SubjectReportReply> replyMsg = new TibcoMessage<SubjectReportReply>();
                replyMsg.Body.MachineName = request.Body.MachineName;
                replyMsg.Body.SubjectName = request.Body.SubjectName;
                replyMsg.Body.Acknowledge = "1";
                this.SendMessage(replyMsg.ToMessage());
            }
            else if (msgHeader.MessageName == "SubjectReportReply")
            {
                bReceiveReponsed = true;
                TibcoMessage<SubjectReportReply> replyMsg = new TibcoMessage<SubjectReportReply>();
                replyMsg.Parse(message);
                this.Handle(replyMsg);

            }
            else if (msgHeader.MessageName == "DcpPlanRequest")
            {
                TibcoMessage<DcpPlanRequest> request = new TibcoMessage<DcpPlanRequest>();
                request.Parse(message);
                this.Handle(request);
            }
            else if (msgHeader.MessageName == "DcpPlanReply")
            {
                TibcoMessage<DcpPlanReply> replyMsg = new TibcoMessage<DcpPlanReply>();
                replyMsg.Parse(message);
                this.Handle(replyMsg);
            }
            else if (msgHeader.MessageName == "TraceListRequest")
            {
                TibcoMessage<TraceListRequest> request = new TibcoMessage<TraceListRequest>();
                request.Parse(message);
                this.Handle(request);
            }
            else if (msgHeader.MessageName == "TransferListRequest")
            {
                TibcoMessage<TransferListRequest> request = new TibcoMessage<TransferListRequest>();
                request.Parse(message);
                this.Handle(request);
            }
            else if (msgHeader.MessageName == "PortStateChangedRequest")
            {
                TibcoMessage<PortStateChangeRequest> request = new TibcoMessage<PortStateChangeRequest>();
                request.Parse(message);
                this.Handle(request);
            }
            else if (msgHeader.MessageName == "MachineStateChangedRequest")
            {
                TibcoMessage<MachineStateChangeRequest> request = new TibcoMessage<MachineStateChangeRequest>();
                request.Parse(message);
                this.Handle(request);
            }
            else if (msgHeader.MessageName == "ControlStateRequest")
            {
                TibcoMessage<ControlStateChangeRequest> request = new TibcoMessage<ControlStateChangeRequest>();
                request.Parse(message);
                this.Handle(request);
            }
            else if (msgHeader.MessageName == "CarrierIDReadReply")
            {
                TibcoMessage<CarrierIDReadReply> replyMsg = new TibcoMessage<CarrierIDReadReply>();
                replyMsg.Parse(message);
                this.Handle(replyMsg);
            }
        }

        public void Handle(TibcoMessage<TransferListRequest> request)
        {
            TibcoMessage<TransferListReply> replyMsg = new TibcoMessage<TransferListReply>();
            replyMsg.Header.MachineName = request.Header.MachineName;
            replyMsg.Header.TransactionId = request.Header.TransactionId;
            replyMsg.Header.OriginalSourceSubjectName = request.Header.OriginalSourceSubjectName;

            replyMsg.Body.CommandID = request.Body.CommandID;
            replyMsg.Body.CarrierID = request.Body.CarrierID;
            replyMsg.Body.BoxIDList = request.Body.BoxIDList;
            replyMsg.Body.FGCode = request.Body.FGCode;
            replyMsg.Body.Source = request.Body.Source;
            replyMsg.Body.Destination = request.Body.Destination;
            replyMsg.Body.Priority = request.Body.Priority;

            this.SendMessage(replyMsg.ToMessage());

            TransferWorkItem a = new TransferWorkItem();
            a.CommandID = request.Body.CommandID;
            a.CarrierID = request.Body.CarrierID;
            a.Source = request.Body.Source;
            a.Description = request.Body.Destination;
            a.Priority = Convert.ToInt32(request.Body.Priority);
            a.CommandType = Lifter.Global.Device.TransferCommandType.TRANSFER;

            //this.LftSem.LDispatcher.AddNewTransferQueue(a);
        }

        public void Handle(TibcoMessage<ControlStateChangeRequest> request)
        {
            TibcoMessage<ControlStateChangeReply> replyMsg = new TibcoMessage<ControlStateChangeReply>();
            replyMsg.Header.MachineName = request.Header.MachineName;
            replyMsg.Header.TransactionId = request.Header.TransactionId;
            replyMsg.Header.OriginalSourceSubjectName = request.Header.OriginalSourceSubjectName;

            replyMsg.Body.MachineName = request.Body.MachineName;
            replyMsg.Body.ControlState = request.Body.ControlState;

            this.SendMessage(replyMsg.ToMessage());

            if (request.Body.ControlState == "0")
                this.LftSem.HostControlState = enumHostControlState.SC_OFFLINE_HOST;
            else if (request.Body.ControlState == "1")
                this.LftSem.HostControlState = enumHostControlState.SC_ONLINE_HOST;
        }

        public void Handle(TibcoMessage<MachineStateChangeRequest> request)
        {
            TibcoMessage<MachineStateChangeReply> replyMsg = new TibcoMessage<MachineStateChangeReply>();
            replyMsg.Header.MachineName = request.Header.MachineName;
            replyMsg.Header.TransactionId = request.Header.TransactionId;
            replyMsg.Header.OriginalSourceSubjectName = request.Header.OriginalSourceSubjectName;

            replyMsg.Body.MachineName = request.Body.MachineName;
            replyMsg.Body.MachineState = request.Body.MachineState;

            this.SendMessage(replyMsg.ToMessage());

            if (request.Body.MachineState == "0")
                this.LftSem.SCStatemode = enumSCStateMode.SC_PAUSED;
            else if (request.Body.MachineState == "1")
                this.LftSem.SCStatemode = enumSCStateMode.SC_AUTO;
        }

        public void Handle(TibcoMessage<PortStateChangeRequest> request)
        {
            TibcoMessage<PortStateChangeReply> replyMsg = new TibcoMessage<PortStateChangeReply>();
            replyMsg.Header.MachineName = request.Header.MachineName;
            replyMsg.Header.TransactionId = request.Header.TransactionId;
            replyMsg.Header.OriginalSourceSubjectName = request.Header.OriginalSourceSubjectName;

            replyMsg.Body.MachineName = request.Body.MachineName;
            replyMsg.Body.PortID = request.Body.PortID;
            replyMsg.Body.PortInOutType = request.Body.PortInOutType;

            this.SendMessage(replyMsg.ToMessage());

            LifterPort lifterPort = this.LftSem.GetLifterPort(request.Body.PortID);
            if (lifterPort != null)
            {
                if (request.Body.PortInOutType == "2")
                    lifterPort.DoPortInOutModeChange(true);
                else if (request.Body.PortInOutType == "1")
                    lifterPort.DoPortInOutModeChange(false);
            }
        }

        public void Handle(TibcoMessage<SubjectReportReply> reply)
        {
            string str1 = reply.Body.MachineName;
            string str2 = reply.Body.SubjectName;
            string str3 = reply.Body.Acknowledge;

            TibcoMessage<DcpPlanRequest> dcpPlanRequest = new TibcoMessage<DcpPlanRequest>();
            dcpPlanRequest.Header.MachineName = this.LftSem.HostID;
            dcpPlanRequest.Header.OriginalSourceSubjectName = _recvComParam.Subject;
            dcpPlanRequest.Header.TransactionId = DateTime.Now.ToString("yyyyMMddHHmmssffffff");

            dcpPlanRequest.Body.MachineName = this.LftSem.HostID;

            this.SendMessage(dcpPlanRequest.ToMessage());
        }

        public void Handle(TibcoMessage<DcpPlanReply> message)
        {
            string str1 = message.Body.MachineName;
            string str3 = message.Body.Acknowledge;

            LftSem.HostControlState = enumHostControlState.SC_ONLINE_HOST;
        }
        public void Handle(TibcoMessage<CarrierIDReadReply> message)
        {
            string PortID = message.Body.Carrierloc;
            string ReturnCode = message.ReturnSet.ReturnCode;
            if (!string.IsNullOrEmpty(PortID) && !string.IsNullOrEmpty(ReturnCode))
            {
                //mes回复0，表示当前BOX站点正常，可以继续下一流程
                if ("0".Equals(ReturnCode))
                {
                    if (PortID.Contains("P21"))
                    {
                        LftSem.O_JudgeBoxOperation = 1;
                    }
                    else if (PortID.Contains("P22"))
                    {
                        LftSem.O_JudgeBoxOperation = 2;
                    }
                    else if (PortID.Contains("P31"))
                    {
                        LftSem.O_JudgeBoxOperation = 3;
                    }
                    else if (PortID.Contains("P32"))
                    {
                        LftSem.O_JudgeBoxOperation = 4;
                    }
                }
                //表示当前BOX站点异常，箱子退出Port口
                else
                {
                    LftSem.O_JudgeBoxOperation = 0;
                }
            }
        }


        public void Handle(TibcoMessage<DcpPlanRequest> request)
        {
            TibcoMessage<DcpPlanReply> replyMsg = new TibcoMessage<DcpPlanReply>();
            replyMsg.Header.MachineName = request.Header.MachineName;
            replyMsg.Header.OriginalSourceSubjectName = request.Header.OriginalSourceSubjectName;
            replyMsg.Header.TransactionId = request.Header.TransactionId;

            replyMsg.Body.MachineName = request.Body.MachineName;
            if (request.Body.MachineName != this.LftSem.HostID)
            {
                replyMsg.Body.Acknowledge = "1";
            }
            else
            {

                replyMsg.Body.Acknowledge = "0";
            }
            this.SendMessage(replyMsg.ToMessage());
        }

        public void Handle(TibcoMessage<TraceListRequest> request)
        {
            TibcoMessage<TraceListReply> replyMsg = new TibcoMessage<TraceListReply>();

            replyMsg.Header.MachineName = request.Header.MachineName;
            replyMsg.Header.OriginalSourceSubjectName = request.Header.OriginalSourceSubjectName;
            replyMsg.Header.TransactionId = request.Header.TransactionId;

            replyMsg.Body.MachineName = request.Body.MachineName;
            replyMsg.Body.UnitName = request.Body.UnitName;
            replyMsg.Body.TRID = request.Body.TRID;
            replyMsg.Body.TOTSMP = request.Body.TOTSMP;
            replyMsg.Body.TIAACK = "0";

            this.SendMessage(replyMsg.ToMessage());

            int hh = Convert.ToInt32(request.Body.DSPER.Substring(0, 2));
            int mm = Convert.ToInt32(request.Body.DSPER.Substring(2, 2));
            int ss = Convert.ToInt32(request.Body.DSPER.Substring(4, 2));
            int cc = Convert.ToInt32(request.Body.DSPER.Substring(6, 2));


            _traceRequestData.DSPER = hh * 3600 * 1000 + mm * 60 * 1000 + ss * 1000 + cc * 10;
            _traceRequestData.TOTSMP = Convert.ToInt32(request.Body.TOTSMP);
            _traceRequestData.GroupSize = Convert.ToInt32(request.Body.REPGSZ);
            _traceRequestData.SVList = request.Body.SVIDList;
            _traceRequestData.TRID = request.Body.TRID;

            if (_traceRequestData.DSPER > 0 && _traceRequestData.TOTSMP != 0)
            {
                _traceDataTimer.Interval = _traceRequestData.DSPER;
            }
            else
            {
                _traceDataTimer.Interval = 5000;
            }
        }

        public override void Reopen()
        {
            this.Open();
        }

        public override void Close()
        {
        }

        public override void TerminateSEComDriver()
        {
            TIBCO.Rendezvous.Environment.Close();
        }

        public override void ReplyMessage(string sxfx, object secsTransaction, SecsValue secsValue)
        {
        }

        public override void SendMessage(string sxfx, string param, object obj1)
        {
            this.SendMessage(sxfx, param, new object[] { obj1 });
        }

        public override void SendMessage(string sxfx, string param, object obj1, object obj2)
        {
            this.SendMessage(sxfx, param, new object[] { obj1, obj2 });
        }

        public override void SendMessage(string sxfx, string param, object obj1, object obj2, object obj3)
        {
            this.SendMessage(sxfx, param, new object[] { obj1, obj2, obj3 });
        }

        public override void SendMessage(string sxfx, string param, object obj1, object obj2, object obj3, object obj4)
        {
            this.SendMessage(sxfx, param, new object[] { obj1, obj2, obj3, obj4 });
        }

        public override void SendMessage(string sxfx, string param, object obj1, object obj2, object obj3, object obj4, object obj5)
        {
            this.SendMessage(sxfx, param, new object[] { obj1, obj2, obj3, obj4, obj5 });
        }

        public override void SendMessage(string sxfx, object obj1)
        {
            this.SendMessage(sxfx, null, new object[] { obj1 });
        }

        public override void SendMessage(string sxfx, object obj1, object obj2)
        {
            this.SendMessage(sxfx, null, new object[] { obj1, obj2 });
        }

        public override void SendMessage(string sxfx, object obj1, object obj2, object obj3)
        {
            this.SendMessage(sxfx, null, new object[] { obj1, obj2, obj3 });
        }

        public override void SendMessage(string sxfx, object obj1, object obj2, object obj3, object obj4)
        {
            this.SendMessage(sxfx, null, new object[] { obj1, obj2, obj3, obj4 });
        }

        public override void SendMessage(string sxfx, object obj1, object obj2, object obj3, object obj4, object obj5)
        {
            this.SendMessage(sxfx, null, new object[] { obj1, obj2, obj3, obj4, obj5 });
        }

        public override void SendMessage(string sxfx, object[] objs)
        {
            this.SendMessage(sxfx, null, objs);
        }

        public override void SendMessage(string sxfx, string param, object[] values)
        {
            if (param != null)
            {
                if (this.LftSem.HostControlState != enumHostControlState.SC_ONLINE_HOST)
                {
                    if (sxfx == "S6F11" && param == "3")
                    {
                        this.SendS6F11(values, param);
                        return;
                    }
                    if (sxfx == "S6F11" && param == "1")
                    {
                        this.SendS6F11(values, param);
                        return;
                    }
                    return;
                }
            }
            switch (sxfx)
            {
                case "S1F1":
                    this.SendS1F1();
                    break;
                case "S10F1":
                    this.SendS10F1();
                    break;
                case "S1F13":
                    this.SendS1F13("MDLN", "SOFTVER");
                    break;
                case "S2F17":
                    this.SendS2F17();
                    break;
                case "S5F1":
                    this.SendS5F1(param, (EcpAlarm)values[0]);
                    break;
                case "S6F11":
                    this.SendS6F11(values, param);
                    break;
                case "S6F13":
                    this.SendS6F13();
                    break;
            }
        }

        private void SendS1F1()
        {
            TibcoMessage<SubjectReportRequest> subjectReportMsg = new TibcoMessage<SubjectReportRequest>();
            subjectReportMsg.Header.MachineName = this.LftSem.HostID;
            subjectReportMsg.Header.OriginalSourceSubjectName = this._recvComParam.Subject;
            subjectReportMsg.Header.TransactionId = DateTime.Now.ToString("yyyyMMddHHmmssffffff");

            subjectReportMsg.Body.MachineName = this.LftSem.HostID;
            subjectReportMsg.Body.SubjectName = _recvComParam.Subject;

            this.SendMessage(subjectReportMsg.ToMessage());
        }

        private void SendS10F1()
        {

        }

        private void SendS1F13(string MDLN, string SOFTVER)
        {

        }

        private void SendS2F17()
        {

        }

        private void SendS5F1(string param, EcpAlarm alarm)
        {
            TibcoMessage<AlarmEventReport> reportMsg = new TibcoMessage<AlarmEventReport>();
            reportMsg.Header.MachineName = this.LftSem.HostID;
            reportMsg.Header.OriginalSourceSubjectName = _recvComParam.Subject;
            reportMsg.Header.TransactionId = DateTime.Now.ToString("yyyyMMddHHmmssffffff");

            reportMsg.Body.AlarmID = alarm.ALID.ToString();
            reportMsg.Body.AlarmText = alarm.ALTX;
            reportMsg.Body.UnitID = alarm.UnitID;
            reportMsg.Body.MachineName = this.LftSem.HostID;

            if (alarm.AlarmSet)
                reportMsg.Body.EventID = "102";
            else
                reportMsg.Body.EventID = "101";

            if (reportMsg.Body.UnitID != "BOXLFT14_S02")
            {
                this.SendMessage(reportMsg.ToMessage());
            }
        }

        private void SendS6F11(object[] values, string param)
        {
            if (param == "1")
            {
                if (values.Length > 0)
                {
                    LifterSEM lifterSEM = values[0] as LifterSEM;
                    if (lifterSEM != null)
                    {
                        TibcoMessage<ControlStateEventReport> reportMsg = new TibcoMessage<ControlStateEventReport>();
                        reportMsg.Header.MachineName = this.LftSem.HostID;
                        reportMsg.Header.OriginalSourceSubjectName = _recvComParam.Subject;
                        reportMsg.Header.TransactionId = DateTime.Now.ToString("yyyyMMddHHmmssffffff");

                        reportMsg.Body.MachineName = this.LftSem.HostID;
                        reportMsg.Body.UnitID = this.LftSem.HostID;
                        reportMsg.Body.EventID = lifterSEM.HostControlState == enumHostControlState.SC_ONLINE_HOST ? "3" : "1";

                        this.SendMessage(reportMsg.ToMessage());
                    }
                }
            }
            else if (param == "401") //Port InService
            {
                if (values.Length > 0)
                {
                    LifterPort lifterPort = values[0] as LifterPort;
                    if (lifterPort != null)
                    {
                        TibcoMessage<PortStateEventReport> reportMsg = new TibcoMessage<PortStateEventReport>();
                        reportMsg.Header.MachineName = this.LftSem.HostID;
                        reportMsg.Header.OriginalSourceSubjectName = _recvComParam.Subject;
                        reportMsg.Header.TransactionId = DateTime.Now.ToString("yyyyMMddHHmmssffffff");

                        reportMsg.Body.MachineName = this.LftSem.HostID;
                        reportMsg.Body.PortID = lifterPort.HostID;
                        reportMsg.Body.PortInOutType = lifterPort.PortInOutMode == enumLifterPortDirection.IN ? "1" : lifterPort.PortInOutMode == enumLifterPortDirection.OUT ? "2" : "3";
                        reportMsg.Body.EventID = "401";

                        this.SendMessage(reportMsg.ToMessage());
                    }
                }
            }
            else if (param == "402") //Port Outof Service
            {
                if (values.Length > 0)
                {
                    LifterPort lifterPort = values[0] as LifterPort;
                    if (lifterPort != null)
                    {
                        TibcoMessage<PortStateEventReport> reportMsg = new TibcoMessage<PortStateEventReport>();
                        reportMsg.Header.MachineName = this.LftSem.HostID;
                        reportMsg.Header.OriginalSourceSubjectName = _recvComParam.Subject;
                        reportMsg.Header.TransactionId = DateTime.Now.ToString("yyyyMMddHHmmssffffff");

                        reportMsg.Body.MachineName = this.LftSem.HostID;
                        reportMsg.Body.PortID = lifterPort.HostID;
                        reportMsg.Body.PortInOutType = lifterPort.PortInOutMode == enumLifterPortDirection.IN ? "1" : lifterPort.PortInOutMode == enumLifterPortDirection.OUT ? "2" : "3";
                        reportMsg.Body.EventID = "402";

                        this.SendMessage(reportMsg.ToMessage());
                    }
                }
            }
            else if (param == "405") //Port Type Changed
            {
                if (values.Length > 0)
                {
                    LifterPort lifterPort = values[0] as LifterPort;
                    if (lifterPort != null)
                    {
                        TibcoMessage<PortStateEventReport> reportMsg = new TibcoMessage<PortStateEventReport>();
                        reportMsg.Header.MachineName = this.LftSem.HostID;
                        reportMsg.Header.OriginalSourceSubjectName = _recvComParam.Subject;
                        reportMsg.Header.TransactionId = DateTime.Now.ToString("yyyyMMddHHmmssffffff");

                        reportMsg.Body.MachineName = this.LftSem.HostID;
                        reportMsg.Body.PortID = lifterPort.HostID;
                        reportMsg.Body.PortInOutType = lifterPort.PortInOutMode == enumLifterPortDirection.IN ? "1" : lifterPort.PortInOutMode == enumLifterPortDirection.OUT ? "2" : "3";
                        reportMsg.Body.EventID = "406";

                        this.SendMessage(reportMsg.ToMessage());
                    }
                }
            }
            else if (param == "601")  //Port Carrier ID Read done.
            {
                if (values.Length > 0)
                {
                    LifterPort lifterPort = values[0] as LifterPort;
                    if (lifterPort != null)
                    {
                        TibcoMessage<CarrierIDReadEventReport> reportMsg = new TibcoMessage<CarrierIDReadEventReport>();
                        reportMsg.Header.MachineName = this.LftSem.HostID;
                        reportMsg.Header.OriginalSourceSubjectName = _recvComParam.Subject;
                        reportMsg.Header.TransactionId = DateTime.Now.ToString("yyyyMMddHHmmssffffff");

                        reportMsg.Body.MachineName = this.LftSem.HostID;
                        reportMsg.Body.UnitID = lifterPort.HostID;
                        reportMsg.Body.CarrierID = lifterPort.CarrierId;
                        reportMsg.Body.CarrierLocation = lifterPort.HostID;
                        reportMsg.Body.IDReadStatus = lifterPort.InputBCRReadStatus == enumIDReadState.NO_CST ? "1" : "0";

                        this.SendMessage(reportMsg.ToMessage());
                    }
                }
            }
            else if (param == "101") //SCState: AUTO
            {
                if (values.Length > 0)
                {
                    LifterSEM lifterSEM = values[0] as LifterSEM;
                    if (lifterSEM != null)
                    {
                        TibcoMessage<SCStateEventReport> reportMsg = new TibcoMessage<SCStateEventReport>();
                        reportMsg.Header.MachineName = this.LftSem.HostID;
                        reportMsg.Header.OriginalSourceSubjectName = _recvComParam.Subject;
                        reportMsg.Header.TransactionId = DateTime.Now.ToString("yyyyMMddHHmmssffffff");

                        reportMsg.Body.MachineName = this.LftSem.HostID;
                        reportMsg.Body.UnitID = this.LftSem.HostID;
                        reportMsg.Body.SCStatus = Convert.ToInt32(lifterSEM.SCStatemode).ToString("00");

                        this.SendMessage(reportMsg.ToMessage());
                    }
                }
            }
            else if (param == "102") //SCState: PAUSED
            {
                if (values.Length > 0)
                {
                    LifterSEM lifterSEM = values[0] as LifterSEM;
                    if (lifterSEM != null)
                    {
                        TibcoMessage<SCStateEventReport> reportMsg = new TibcoMessage<SCStateEventReport>();
                        reportMsg.Header.MachineName = this.LftSem.HostID;
                        reportMsg.Header.OriginalSourceSubjectName = _recvComParam.Subject;
                        reportMsg.Header.TransactionId = DateTime.Now.ToString("yyyyMMddHHmmssffffff");

                        reportMsg.Body.MachineName = this.LftSem.HostID;
                        reportMsg.Body.UnitID = this.LftSem.HostID;
                        reportMsg.Body.SCStatus = Convert.ToInt32(lifterSEM.SCStatemode).ToString("00");

                        this.SendMessage(reportMsg.ToMessage());
                    }
                }
            }
            else if (param == "104") //SCState: PAUSING
            {
                if (values.Length > 0)
                {
                    LifterSEM lifterSEM = values[0] as LifterSEM;
                    if (lifterSEM != null)
                    {
                        TibcoMessage<SCStateEventReport> reportMsg = new TibcoMessage<SCStateEventReport>();
                        reportMsg.Header.MachineName = this.LftSem.HostID;
                        reportMsg.Header.OriginalSourceSubjectName = _recvComParam.Subject;
                        reportMsg.Header.TransactionId = DateTime.Now.ToString("yyyyMMddHHmmssffffff");

                        reportMsg.Body.MachineName = this.LftSem.HostID;
                        reportMsg.Body.UnitID = this.LftSem.HostID;
                        reportMsg.Body.SCStatus = Convert.ToInt32(lifterSEM.SCStatemode).ToString("00");

                        this.SendMessage(reportMsg.ToMessage());
                    }
                }
            }
            else if (param == "301") //CarrierState:CarrierRemoved
            {
                if (values.Length > 0)
                {
                    Carrier carrier = values[0] as Carrier;
                    if (carrier != null)
                    {
                        TibcoMessage<CarrierStateEventReport> reportMsg = new TibcoMessage<CarrierStateEventReport>();
                        reportMsg.Header.MachineName = this.LftSem.HostID;
                        reportMsg.Header.OriginalSourceSubjectName = _recvComParam.Subject;
                        reportMsg.Header.TransactionId = DateTime.Now.ToString("yyyyMMddHHmmssffffff");

                        reportMsg.Body.MachineName = this.LftSem.HostID;
                        reportMsg.Body.CarrierID = carrier.CarrierId;
                        reportMsg.Body.CarrierLocation = carrier.CarrierLoc == "BOXLFT14_S02" ? "BOXLFT14_S01" : carrier.CarrierLoc;
                        reportMsg.Body.EventID = "303";

                        this.SendMessage(reportMsg.ToMessage());
                    }
                }
            }
            else if (param == "303")//CarrierState:CarrierWaitIn
            {
                if (values.Length > 0)
                {
                    Carrier carrier = values[1] as Carrier;
                    if (carrier != null)
                    {
                        TibcoMessage<CarrierStateEventReport> reportMsg = new TibcoMessage<CarrierStateEventReport>();
                        reportMsg.Header.MachineName = this.LftSem.HostID;
                        reportMsg.Header.OriginalSourceSubjectName = _recvComParam.Subject;
                        reportMsg.Header.TransactionId = DateTime.Now.ToString("yyyyMMddHHmmssffffff");

                        reportMsg.Body.MachineName = this.LftSem.HostID;
                        reportMsg.Body.CarrierID = carrier.CarrierId;
                        reportMsg.Body.CarrierLocation = carrier.CarrierLoc == "BOXLFT14_S02" ? "BOXLFT14_S01" : carrier.CarrierLoc;
                        reportMsg.Body.EventID = "308";

                        this.SendMessage(reportMsg.ToMessage());
                    }
                }
            }
            else if (param == "304")//CarrierState:CarrierWaitOut
            {
                if (values.Length > 0)
                {
                    Carrier carrier = values[0] as Carrier;
                    if (carrier != null)
                    {
                        TibcoMessage<CarrierStateEventReport> reportMsg = new TibcoMessage<CarrierStateEventReport>();
                        reportMsg.Header.MachineName = this.LftSem.HostID;
                        reportMsg.Header.OriginalSourceSubjectName = _recvComParam.Subject;
                        reportMsg.Header.TransactionId = DateTime.Now.ToString("yyyyMMddHHmmssffffff");

                        reportMsg.Body.MachineName = this.LftSem.HostID;
                        reportMsg.Body.CarrierID = carrier.CarrierId;
                        reportMsg.Body.CarrierLocation = carrier.CarrierLoc == "BOXLFT14_S02" ? "BOXLFT14_S01" : carrier.CarrierLoc;
                        reportMsg.Body.EventID = "309";

                        this.SendMessage(reportMsg.ToMessage());
                    }
                }
            }
            else if (param == "305")//CarrierState:CarrierLocationChanged
            {
                if (values.Length > 0)
                {
                    Carrier carrier = values[0] as Carrier;
                    if (carrier != null)
                    {
                        TibcoMessage<CarrierStateEventReport> reportMsg = new TibcoMessage<CarrierStateEventReport>();
                        reportMsg.Header.MachineName = this.LftSem.HostID;
                        reportMsg.Header.OriginalSourceSubjectName = _recvComParam.Subject;
                        reportMsg.Header.TransactionId = DateTime.Now.ToString("yyyyMMddHHmmssffffff");

                        reportMsg.Body.MachineName = this.LftSem.HostID;
                        reportMsg.Body.CarrierID = carrier.CarrierId;
                        reportMsg.Body.CarrierLocation = carrier.CarrierLoc == "BOXLFT14_S02" ? "BOXLFT14_S01" : carrier.CarrierLoc;
                        reportMsg.Body.EventID = "311";

                        this.SendMessage(reportMsg.ToMessage());
                    }
                }
            }
            else if (param == "306")//CarrierState:CarrierTransferring
            {
                if (values.Length > 0)
                {
                    Carrier carrier = values[0] as Carrier;
                    if (carrier != null)
                    {
                        TibcoMessage<CarrierStateEventReport> reportMsg = new TibcoMessage<CarrierStateEventReport>();
                        reportMsg.Header.MachineName = this.LftSem.HostID;
                        reportMsg.Header.OriginalSourceSubjectName = _recvComParam.Subject;
                        reportMsg.Header.TransactionId = DateTime.Now.ToString("yyyyMMddHHmmssffffff");

                        reportMsg.Body.MachineName = this.LftSem.HostID;
                        reportMsg.Body.CarrierID = carrier.CarrierId;
                        reportMsg.Body.CarrierLocation = carrier.CarrierLoc == "BOXLFT14_S02" ? "BOXLFT14_S01" : carrier.CarrierLoc;
                        reportMsg.Body.EventID = "307";

                        this.SendMessage(reportMsg.ToMessage());
                    }
                }
            }
            else if (param == "403") //Shuttle InService
            {
                if (values.Length > 0)
                {
                    Vehicle vehicle = values[0] as Vehicle;
                    if (vehicle != null)
                    {
                        TibcoMessage<LifterShuttleStateEventReport> reportMsg = new TibcoMessage<LifterShuttleStateEventReport>();
                        reportMsg.Header.MachineName = this.LftSem.HostID;
                        reportMsg.Header.OriginalSourceSubjectName = _recvComParam.Subject;
                        reportMsg.Header.TransactionId = DateTime.Now.ToString("yyyyMMddHHmmssffffff");

                        reportMsg.Body.MachineName = this.LftSem.HostID;
                        reportMsg.Body.ShuttleID = vehicle.HostID;
                        reportMsg.Body.EventID = "701";

                        if (reportMsg.Body.ShuttleID == "BOXLFT14_S01")
                        {
                            this.SendMessage(reportMsg.ToMessage());
                        }
                    }
                }
            }
            else if (param == "404") //Shuttle OutOfService
            {
                if (values.Length > 0)
                {
                    Vehicle vehicle = values[0] as Vehicle;
                    if (vehicle != null)
                    {
                        TibcoMessage<LifterShuttleStateEventReport> reportMsg = new TibcoMessage<LifterShuttleStateEventReport>();
                        reportMsg.Header.MachineName = this.LftSem.HostID;
                        reportMsg.Header.OriginalSourceSubjectName = _recvComParam.Subject;
                        reportMsg.Header.TransactionId = DateTime.Now.ToString("yyyyMMddHHmmssffffff");

                        reportMsg.Body.MachineName = this.LftSem.HostID;
                        reportMsg.Body.ShuttleID = vehicle.HostID;
                        reportMsg.Body.EventID = "702";

                        if (reportMsg.Body.ShuttleID == "BOXLFT14_S01")
                        {
                            this.SendMessage(reportMsg.ToMessage());
                        }
                    }
                }
            }
            else if (param == "603") //ShuttleLocationChanged
            {
                if (values.Length > 0)
                {
                    Vehicle vehicle = values[0] as Vehicle;
                    if (vehicle != null)
                    {
                        TibcoMessage<ShuttleLocationChangedinfoEventReport> reportMsg = new TibcoMessage<ShuttleLocationChangedinfoEventReport>();
                        reportMsg.Header.MachineName = this.LftSem.HostID;
                        reportMsg.Header.OriginalSourceSubjectName = _recvComParam.Subject;
                        reportMsg.Header.TransactionId = DateTime.Now.ToString("yyyyMMddHHmmssffffff");

                        reportMsg.Body.MachineName = this.LftSem.HostID;
                        reportMsg.Body.CommandID = vehicle.CommandId;
                        reportMsg.Body.ShuttleID = vehicle.HostID;
                        reportMsg.Body.LocationID = string.Format("L{0}0", vehicle.VehicleLocation);
                        reportMsg.Body.EventID = "603";

                        if (reportMsg.Body.ShuttleID == "BOXLFT14_S01")
                        {
                            this.SendMessage(reportMsg.ToMessage());
                        }
                    }
                }
            }
            else if (param == "502") //Machine InService
            {
                if (values.Length > 0)
                {
                    LifterSEM lifterSEM = values[0] as LifterSEM;
                    if (lifterSEM != null)
                    {
                        TibcoMessage<LifterStateEventReport> reportMsg = new TibcoMessage<LifterStateEventReport>();
                        reportMsg.Header.MachineName = this.LftSem.HostID;
                        reportMsg.Header.OriginalSourceSubjectName = _recvComParam.Subject;
                        reportMsg.Header.TransactionId = DateTime.Now.ToString("yyyyMMddHHmmssffffff");

                        reportMsg.Body.MachineName = this.LftSem.HostID;
                        reportMsg.Body.EventID = "501";

                        this.SendMessage(reportMsg.ToMessage());
                    }
                }
            }
            else if (param == "503") //Machine OutOfService
            {
                if (values.Length > 0)
                {
                    LifterSEM lifterSEM = values[0] as LifterSEM;
                    if (lifterSEM != null)
                    {
                        TibcoMessage<LifterStateEventReport> reportMsg = new TibcoMessage<LifterStateEventReport>();
                        reportMsg.Header.MachineName = this.LftSem.HostID;
                        reportMsg.Header.OriginalSourceSubjectName = _recvComParam.Subject;
                        reportMsg.Header.TransactionId = DateTime.Now.ToString("yyyyMMddHHmmssffffff");

                        reportMsg.Body.MachineName = this.LftSem.HostID;
                        reportMsg.Body.EventID = "502";

                        this.SendMessage(reportMsg.ToMessage());
                    }
                }
            }
            else if (param == "602") //OperationInitiatedAction
            {
                if (values.Length > 0)
                {
                    TransferWorkItem workItem = values[0] as TransferWorkItem;
                    if (workItem != null)
                    {
                        TibcoMessage<OperatorInitiatedActionEventReport> reportMsg = new TibcoMessage<OperatorInitiatedActionEventReport>();
                        reportMsg.Header.MachineName = this.LftSem.HostID;
                        reportMsg.Header.OriginalSourceSubjectName = _recvComParam.Subject;
                        reportMsg.Header.TransactionId = DateTime.Now.ToString("yyyyMMddHHmmssffffff");

                        reportMsg.Body.MachineName = this.LftSem.HostID;
                        reportMsg.Body.CommandID = workItem.CommandID;
                        reportMsg.Body.CarrierID = workItem.CarrierID;
                        reportMsg.Body.CommandType = workItem.CommandType.Value().ToString();
                        reportMsg.Body.Source = workItem.Source;
                        reportMsg.Body.Destination = workItem.Dest;
                        reportMsg.Body.Priority = workItem.Priority.ToString();
                        reportMsg.Body.EventID = "602";

                        this.SendMessage(reportMsg.ToMessage());
                    }
                }
            }
            else if (param == "207") //TransferCompleted
            {
                if (values.Length > 0)
                {
                    TransferWorkItem workItem = values[0] as TransferWorkItem;
                    if (workItem != null)
                    {
                        TibcoMessage<TransferCommandEventReport> reportMsg = new TibcoMessage<TransferCommandEventReport>();
                        reportMsg.Header.MachineName = this.LftSem.HostID;
                        reportMsg.Header.OriginalSourceSubjectName = _recvComParam.Subject;
                        reportMsg.Header.TransactionId = DateTime.Now.ToString("yyyyMMddHHmmssffffff");

                        reportMsg.Body.MachineName = this.LftSem.HostID;
                        reportMsg.Body.CommandID = workItem.CommandID;
                        reportMsg.Body.CarrierID = workItem.CarrierID;
                        reportMsg.Body.CarrierLocation = workItem.CarrierLoc == "BOXLFT14_S02" ? "BOXLFT14_S01" : workItem.CarrierLoc;
                        reportMsg.Body.Destination = workItem.Dest;
                        reportMsg.Body.ResultCode = Convert.ToInt32(workItem.ResultCode).ToString();
                        reportMsg.Body.EventID = "207";

                        this.SendMessage(reportMsg.ToMessage());
                    }
                }
            }
            else if (param == "208") //TransferInitiated
            {
                if (values.Length > 0)
                {
                    TransferWorkItem workItem = values[0] as TransferWorkItem;
                    if (workItem != null)
                    {
                        TibcoMessage<TransferCommandEventReport> reportMsg = new TibcoMessage<TransferCommandEventReport>();
                        reportMsg.Header.MachineName = this.LftSem.HostID;
                        reportMsg.Header.OriginalSourceSubjectName = _recvComParam.Subject;
                        reportMsg.Header.TransactionId = DateTime.Now.ToString("yyyyMMddHHmmssffffff");

                        reportMsg.Body.MachineName = this.LftSem.HostID;
                        reportMsg.Body.CommandID = workItem.CommandID;
                        reportMsg.Body.CarrierID = workItem.CarrierID;
                        reportMsg.Body.CarrierLocation = workItem.CarrierLoc == "BOXLFT14_S02" ? "BOXLFT14_S01" : workItem.CarrierLoc;
                        reportMsg.Body.Destination = workItem.Dest;
                        reportMsg.Body.ResultCode = Convert.ToInt32(workItem.ResultCode).ToString();
                        reportMsg.Body.EventID = "208";

                        this.SendMessage(reportMsg.ToMessage());
                    }
                }
            }
            else if (param == "209") //TransferPaused
            {
                if (values.Length > 0)
                {
                    TransferWorkItem workItem = values[0] as TransferWorkItem;
                    if (workItem != null)
                    {
                        TibcoMessage<TransferCommandEventReport> reportMsg = new TibcoMessage<TransferCommandEventReport>();
                        reportMsg.Header.MachineName = this.LftSem.HostID;
                        reportMsg.Header.OriginalSourceSubjectName = _recvComParam.Subject;
                        reportMsg.Header.TransactionId = DateTime.Now.ToString("yyyyMMddHHmmssffffff");

                        reportMsg.Body.MachineName = this.LftSem.HostID;
                        reportMsg.Body.CommandID = workItem.CommandID;
                        reportMsg.Body.CarrierID = workItem.CarrierID;
                        reportMsg.Body.CarrierLocation = workItem.CarrierLoc == "BOXLFT14_S02" ? "BOXLFT14_S01" : workItem.CarrierLoc;
                        reportMsg.Body.Destination = workItem.Dest;
                        reportMsg.Body.ResultCode = Convert.ToInt32(workItem.ResultCode).ToString();
                        reportMsg.Body.EventID = "209";

                        this.SendMessage(reportMsg.ToMessage());
                    }
                }
            }
            else if (param == "210") //TransferResumed
            {
                if (values.Length > 0)
                {
                    TransferWorkItem workItem = values[0] as TransferWorkItem;
                    if (workItem != null)
                    {
                        TibcoMessage<TransferCommandEventReport> reportMsg = new TibcoMessage<TransferCommandEventReport>();
                        reportMsg.Header.MachineName = this.LftSem.HostID;
                        reportMsg.Header.OriginalSourceSubjectName = _recvComParam.Subject;
                        reportMsg.Header.TransactionId = DateTime.Now.ToString("yyyyMMddHHmmssffffff");

                        reportMsg.Body.MachineName = this.LftSem.HostID;
                        reportMsg.Body.CommandID = workItem.CommandID;
                        reportMsg.Body.CarrierID = workItem.CarrierID;
                        reportMsg.Body.CarrierLocation = workItem.CarrierLoc == "BOXLFT14_S02" ? "BOXLFT14_S01" : workItem.CarrierLoc;
                        reportMsg.Body.Destination = workItem.Dest;
                        reportMsg.Body.ResultCode = Convert.ToInt32(workItem.ResultCode).ToString();
                        reportMsg.Body.EventID = "210";

                        this.SendMessage(reportMsg.ToMessage());
                    }
                }
            }
        }

        private void SendS6F13()
        {

        }

        public override void PassiveOpen()
        {
            throw new NotImplementedException();
        }
    }
}
